package com.qst.service;

import com.qst.dao.MeetingDao;
import com.qst.pojo.Employee;
import com.qst.pojo.Meeting;
import com.qst.util.DataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

/**
 * @author KungSu.
 * @create 2021-06-21 15:06
 */
@Service
public class NotificationsService {
    @Autowired
    MeetingDao meetingDao;

public List<Meeting> findmeeting(Integer id) throws ParseException {
    List<Meeting> meetings =meetingDao.findmeeting(id);
    List<Meeting> m = new LinkedList<>();
    for (Meeting meeting : meetings) {
        if(meeting.getStarttime() == null) {
            continue;
        }
        if (DataUtil.getDayDiffer(new Date(), meeting.getStarttime()) >= 0 && DataUtil.getDayDiffer(new Date(), meeting.getStarttime()) <= 7) {
            m.add(meeting);
        }
    }

    return m;
}
    public List<Meeting> findCancelMeeting(Integer reservationistid) {
        List<Meeting> meetings = meetingDao.findCancelMeeting(reservationistid);
        return meetings;
    }
    public void reMeeting(Integer id){
        meetingDao.reMeeting(id);
    }
    public void delMeeting(Integer id){
        meetingDao.delMeeting(id);
        meetingDao.delMeeting1(id);
    }
    public void cancelMeeting(Integer id){
        meetingDao.cancelMeeting(id);
    }

}
